package com.zpkj.portal.utils;

import java.util.HashMap;

import org.apache.commons.lang.StringUtils;

public class Constant {

	// 阿里云图片服务器地址
	public final static String ALIYUNSERVICE_PATH = "https://baoying365.oss-cn-shanghai.aliyuncs.com";

	// 默认logo
	public final static String LOGO_PATH = "http://zpkj.oss-cn-shanghai.aliyuncs.com/byc_logo/byc_logo.png";

	// 邀请用户的链接地址
	public final static String REFEREELINK_PATH = "https://url/html5/baoyc/invite.html?userCode=";

	public final static String SUCCESS = "success";
	public final static String FALSE = "false";

	public final static String CURRPAGE = "1";// 默认当前页码
	public final static String PAGESIZE = "50";// 默认每页数量

	// 华为消息推送所有用户的标签tagKey
	public final static String HUAWEI_PUSH_TAGKEY_ALLUSER = "allUsers";

	// 用户默认昵称前缀
	public final static String DEFAULTNICK_PREFIX = "用户";
	// 默认个性签名展示
	public final static String DEFAULT_USER_DESC = "这家伙很懒,啥都没留下";

	// 接口返回编码 0000-1999 系统层级 ；2000-2999 用户层级 ；3000-3999 第三方层级 4000-4999 业务层级
	public class ReturnCode {
		public static final String CODE_0000 = "0000";// 系统繁忙，请稍后再试
		public static final String CODE_1000 = "1000";// 成功
		public static final String CODE_1001 = "1001";// 参数为空
		public static final String CODE_1002 = "1002";// 参数格式不正确
		public static final String CODE_1003 = "1003";// 参数值不正确
		public static final String CODE_1009 = "1009";// 当前版本已不支持该功能,请您升级至最新版本
		public static final String CODE_1110 = "1110";// 业务异常
		public static final String CODE_1888 = "1888";// token已失效,请重新登录
		public static final String CODE_1999 = "1999";// 签名校验失败
		public static final String CODE_2001 = "2001";// 用户不存在
		public static final String CODE_2002 = "2002";// 账号已被锁定
		public static final String CODE_2003 = "2003";// 非本人不能操作
		public static final String CODE_2004 = "2004";// 不能自己对自己操作
		public static final String CODE_2005 = "2005";// 账户余额被冻结,无法交易
		public static final String CODE_2006 = "2006";// 余额不足
		public static final String CODE_2101 = "2101";// 手机号已注册
		public static final String CODE_2102 = "2102";// 手机号未注册
		public static final String CODE_2009 = "2009";// 无操作权限
		public static final String CODE_3000 = "3000";// 短信验证码发送异常,请联系管理员
		public static final String CODE_3001 = "3001";// 短信验证码不正确
		public static final String CODE_3002 = "3002";// 短信验证码已失效,请重新获取
		public static final String CODE_3003 = "3003";// 短信验证码错误次数太多,请24小时后重新验证
		public static final String CODE_112300 = "112300";// 接收短信的手机号码为空
		public static final String CODE_160038 = "160038";// 短信验证码发送过频繁
		public static final String CODE_160040 = "160040";// 验证码超出同模板同号码天发送上限
		public static final String CODE_160041 = "160041";// 通知超出同模板同号码天发送上限
		public static final String CODE_160050 = "160050";// 短信发送失败
	}

	public static HashMap<String, String> ReturnCodeInfoMap = new HashMap<String, String>();
	static {
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_0000, "系统繁忙，请稍后再试");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1000, "成功");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1001, "参数为空");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1002, "参数格式不正确");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1003, "参数值不正确");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1009, "当前版本已不支持该功能,请您升级至最新版本");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1110, "业务异常");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1888, "登陆已失效,请重新登录");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_1999, "签名校验失败");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2001, "用户不存在");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2002, "账号已被锁定");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2003, "非本人不能操作");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2004, "不能自己对自己操作");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2005, "账户余额被冻结,无法交易");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2006, "余额不足");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2009, "无操作权限");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2101, "手机号已注册");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_2102, "手机号未注册");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_3000, "短信验证码发送异常,请稍后再试");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_3001, "短信验证码不正确");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_3002, "短信验证码已失效,请重新获取");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_3003, "短信验证码错误次数太多,请24小时后重新验证");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_112300, "接收短信的手机号码为空");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_160038, "短信验证码发送过频繁");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_160040, "验证码超出同模板同号码天发送上限");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_160041, "通知超出同模板同号码天发送上限");
		ReturnCodeInfoMap.put(Constant.ReturnCode.CODE_160050, "短信发送失败");
	}

	// redis中各key值得定义
	public class RedisKey {
		// 注册手机短信校验码:[smsCode_login_]+[手机号]
		public static final String SMSCODE_REGISTER_ = "smsCode_register_";
		// 登陆手机短信校验码:[smsCode_login_]+[手机号]
		public static final String SMSCODE_LOGIN_ = "smsCode_login_";
		// 重置密码手机短信校验码:[smsCode_resetPwd_]+[手机号]
		public static final String SMSCODE_RESETPWD_ = "smsCode_resetPwd_";
		// 修改绑定支付宝短信校验码
		public static final String SMSCODE_BINDINGDRAWALACCOUNT_ = "smsCode_bindingDrawalAccount_";
		// 系统token的key:[token_]+[userId]
		public static final String SYSTEMTOKEN_ = "token_";
	}

	/**
	 * 终端设备类型
	 */
	public class deviceType {
		public static final String ANDROID = "1";
		public static final String IOS = "2";
		public static final String H5 = "3";
	}

	/**
	 * 终端设备类型
	 */
	public static String getDeviceTypeStr(String appDeviceType) {
		if ("1".equals(appDeviceType)) {
			return "android";
		} else if ("2".equals(appDeviceType)) {
			return "iOS";
		} else {
			return "H5";
		}
	}

	public class payStatus {
		public static final int WAIT = 1;
		public static final int SUCCESS = 2;
		public static final int FAIL = 3;
	}

	public class status {
		public static final String SUCCESS = "0";
		public static final String FAIL = "1";
	}

	// 登录方式
	public class loginType {
		public static final String ACCOUNT = "0";// 账户登录
		public static final String SMSCODE = "1";// 验证码登录
		public static final String THIRD = "2";// 第三方
	}

	// 分享参数
	public class shareParam {
		public static final String STATUS = "0";// 0-分享 1-不分享
		public static final String LOGO = "http://url/bycimg_common/cms/tags/share_2x.png";// 第三方
	}

	/**
	 * 将图片的相对路径转成绝对路径
	 */
	public static String getImgFullUrl(String str) {
		if (StringUtils.isEmpty(str)) {
			return "";
		}
		if (str.contains("http://") || str.contains("https://")) {
			return str;
		}
		if (!"/".equals(str.substring(0, 1))) {
			str = "/" + str;
		}
		return ALIYUNSERVICE_PATH + str;
	}

}
